from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html

from .models import Image


# Register your models here.

@admin.register(Image)
class ImageAdmin(admin.ModelAdmin):
    list_display = ['title', 'slug', 'image', 'created', 'operator']
    list_filter = ['created']

    def operator(self, obj):
        return format_html(f'<a href="/admin/images/image/{obj.id}/change/">编辑</a>')

    operator.short_description = '操作'
